﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace SharedGamesClasses {

    // <summary>
    /// ConsoleUtilities.cs provides commonly used Display methods
    /// in the Console version of each games. 
    /// </summary>
    class ConsoleUtilities {
        private static string YES = "Y";
        private static string NO = "N";
        /// <summary>
        /// Asks the user if they wish to play again.
        /// Pre:  none
        /// Post: whether the user wishes to play again.
        /// </summary>
        /// <returns>
        /// true if the user wishes to play again,
        /// false otherwise
        /// </returns>
        public static bool WantToPlayAgain() {
            string input;
            bool validInput = false;
            do {
                Console.Write("Play Again? (Y or N): ");
                input = Console.ReadLine().ToUpper();
                validInput = input == YES || input == NO;
            } while (!validInput);

            return (input == YES);
        } // end WantToPlayAgain


        /// <summary>
        /// Displays a prompt and waits for a key press.
        /// Pre:  prompt to display; not null, nor empty
        /// Post: prompt was displayed and user pressed a key.
        /// </summary>
        /// <param name="prompt">the prompt to display to the user</param>
        public static void WaitForKey(string prompt) {
            Debug.Assert(!String.IsNullOrEmpty(prompt), "prompt != null");

            Console.Write(prompt);
            Console.ReadKey();
            Console.WriteLine();
        } // end WaitForKey


    }
}
